package com.qf.news.service.impl;

import com.qf.news.domain.Admin;
import com.qf.news.mapper.AdminMapper;
import com.qf.news.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Objects;


@Service
@Transactional(rollbackFor = Exception.class)
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;
    @Override
    public Admin adminLogin(String username, String userpwd) {
        List<Admin> admins = adminMapper.selectByName(username);
        for (Admin admin : admins) {
            if (Objects.equals(userpwd, admin.getUserpwd())) {
                return admin;
            }
        }
        return null;
    }

    @Override
    public String deleteuser(String username) {
        return username;
    }

    @Override
    public String deleteLuoyangyuser(String username) {
        return username;
    }
}
